package com.starsea.book.ui.newpage

import android.os.Bundle
import androidx.activity.viewModels
import com.starsea.book.base.VMBaseActivity
import com.starsea.book.databinding.ActivityPrivateDealBinding
import com.starsea.book.ui.config.ConfigViewModel
import com.starsea.book.utils.viewbindingdelegate.viewBinding

/**
 * @author Lee
 * @createTime 2024-01-09 21 GMT+8
 * @desc : 文字编辑
 */
class PrivateDealActivity : VMBaseActivity<ActivityPrivateDealBinding, ConfigViewModel>() {

    override val binding by viewBinding(ActivityPrivateDealBinding::inflate)
    override val viewModel by viewModels<ConfigViewModel>()

    override fun onActivityCreated(savedInstanceState: Bundle?) {

        val type = intent.getStringExtra("type") ?: ""

        viewModel.getDeal(type)
        viewModel.dealResult.observe(this) {
            if (it.status == 200) {
                binding.tvTime.text =
                    "生效日期：${it.data?.effectiveDate?:""}\n更新日期：${it.data?.updateDate?:""}"

                binding.tvContent.text = it.data?.content ?: ""

                title = it.data?.typeName ?: ""
                binding.titleBar.setTitle(it.data?.typeName ?: "")
            }
        }

    }

    override fun setTitle(resId: Int) {
        super.setTitle(resId)
        binding.titleBar.setTitle(resId)
    }


}